package com.lysj.bhp.investment.repository;


import com.lysj.bhp.investment.domain.Dividend;
import com.lysj.bhp.investment.vo.DividendVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;


public interface DividendRepository extends JpaRepository<Dividend, Long> {

    Dividend findTopByOrderByDividentIdDesc();

    Dividend findByUserIdAndCreateTimeBetween(Long userId,Date date,Date date1);

    Dividend findByUserId(Long userId);

    List<Dividend> findByCreateTimeBetween(Date date, Date date1);

    @Query("SELECT new com.lysj.bhp.investment.vo.DividendVo(a.dividend,a.createTime) from Dividend a where  a.createTime >= ?1 AND a.createTime <= ?2 AND a.userId = ?3 ORDER BY a.createTime DESC ")
    Page<DividendVo> findUserDividedRecord(Pageable page, Date begin_createTime, Date end_createTime, Long userId);


    List<Dividend> findByUserIdOrderByCreateTimeDesc(Long userId);
}
